package ke07.pm.reihe5;

import java.lang.reflect.Array;
import java.util.ArrayList;

import ke07.pm.template.HundredItemBag;

public class MyClass<T> implements HundredItemBag<T> {

	private ArrayList<T> bag = new ArrayList<T>();

	/**
	 * @return The total amount of stored items in this bag.
	 */
	public int size() {
		
		if(bag.size() <=100){
		return bag.size();}
		
		else System.out.println("Größer als 100 !!!"); 
			 return 100;

	}

	/**
	 * Puts an object to the Bag.
	 * 
	 * @param obj
	 *            the object to store in the Bag.
	 * @return true if, and only if, an object equal to the given object was
	 *         already contained in the Bag before the given object was added.
	 * @throws NullPointerException
	 *             if the given object is the null reference.
	 */
	public boolean add(T obj) {
		if (obj == null) {
			throw new NullPointerException();
		}

		else if (bag.contains(obj)) {
			bag.add(obj);
			return true;
		}

		else {
			bag.add(obj);
			return false;
		}
	}

	/**
	 * Removes the first occurrence of an object from the Bag.
	 * 
	 * @param obj
	 *            the object to remove.
	 * @return true if, and only if, {@link #count(T)} would return 0 after
	 *         calling this method, i.e. the given object was the last one of
	 *         its kind in the bag or there was nothing to remove.
	 * @throws IllegalArgumentException
	 *             if the given object is the null reference.
	 */
	public boolean remove(T obj) {
		if(obj == null){
			throw new NullPointerException();
		}
		
		//TODO
		
		return false;
	}

	/**
	 * @param obj
	 *            the object to count.
	 * @return Amount of occurrences of this object in the Bag, as defined by
	 *         equals method.
	 */
	public int count(T obj) {
		return 0;
	}

	/**
	 * @param obj
	 *            the object to check for.
	 * @return Whether the given object is contained in the Bag.
	 */
	public boolean contains(T obj) {
		
		if(bag.contains(obj)){
			return true;
		}

		return false;
	}

	/**
	 * @return A copy of all elements in this Bag as an array of T with
	 *         {@link #size()} entries.
	 */
	public T[] toArray() {
		return null;
		//TODO
		
	}
}
